<template>
	<div class="part">
	    <span>数据来源于vdr</span>
		<h2>YTD夜驾</h2>
		<div ref="nightCountryChart" style="width:100%;height:20rem"></div>
		<div class="mt30" ref="nightPersonalChart" style="width:100%;height:20rem"></div>
	</div>
</template>
<script type="text/javascript">
	import echarts from 'echarts'
	export default{
		mounted(){
			this.getNightCountryData();
			this.getNightPersonalData();
		},
		methods:{
			//急加减速
			getNightCountryData(){
				let nightCountryChart = echarts.init(this.$refs.nightCountryChart)
				this.$http.get(this.$parent.nightCountryUrl,{emulateJSON:true})
				.then((response) => {
					// console.log(response);
					if(response){
						this.$parent.nightCountryOption.yAxis.data = response.data[0].type;
						this.$parent.nightCountryOption.series[0].data = response.data[0].data[0];
						nightCountryChart.setOption(this.$parent.nightCountryOption);
					}
				})
			},
			getNightPersonalData(){
				let nightPersonalChart = echarts.init(this.$refs.nightPersonalChart);
				this.$http.get(this.$parent.nightPersonalUrl,{emulateJSON:true})
				.then((response) => {
					// console.log(response);
					if(response){
						// this.$parent.nightPersonalOption.xAxis.data = response.data[0].type;
						let dataLen = response.data[0].data[0].length;
						this.$parent.nightPersonalOption.xAxis.data[dataLen-1] = response.data[0].type[0];
						this.$parent.nightPersonalOption.series.data = response.data[0].data[0];
						nightPersonalChart.setOption(this.$parent.nightPersonalOption);
					}
				})
			}
		}
	}
</script>